<!DOCTYPE html>
<html lang="en">
<!--头部信息-->
<head>
    <meta charset="utf-8">
    <title>审判详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

    <link rel="stylesheet" href="../../../lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../css/public.css" media="all">

    <script src="../../../lib/layui-v2.5.5/layui.js" charset="utf-8"></script>

    <style>
        body {
            background-color: #ffffff;
        }
    </style>

</head>
<!--审判详情(弹出层)-->
<body>
<form id="edit" action="">
    <div class="layui-form layuimini-form">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>基本信息</legend>
        </fieldset>


        <div class="layui-row">
            <div class="layui-col-xs4">
                <div class="grid-demo grid-demo-bg1">
                    <!--编号-->
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">ID：</label>
                        <div class="layui-input-block" id="ffid" style="width: 80%">
                            <label name="ffid" class="layui-form-label-col "></label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="grid-demo">
                    <!--姓名-->
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">姓名：</label>
                        <div class="layui-input-block" id="fname" style="width: 80%">
                            <label name="fname" class="layui-form-label-col "></label>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="layui-row">
            <div class="layui-col-xs4">
                <div class="grid-demo grid-demo-bg1">
                    <!--死因-->
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">死因：</label>
                        <div class="layui-input-block" id="fdieWhy" style="width: 80%">
                            <label name="fdieWhy" class="layui-form-label-col "></label>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-xs6">
                <div class="grid-demo">
                    <!--死因-->
                    <div class="layui-form-item layui-form-text">
                        <label class="layui-form-label">时间：</label>
                        <div class="layui-input-block" id="fdieTime" style="width: 80%">
                            <label name="fdieTime" class="layui-form-label-col "></label>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>审问记录</legend>
        </fieldset>

        <div class="layui-form-item layui-form-text" style="padding-left: 50px;padding-right: 50px">
            <textarea style="resize: none;height: 150px" placeholder="请输入内容" id="desc" class="layui-textarea"></textarea>
        </div>


        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>处理方式</legend>
        </fieldset>

        <div style="padding-left: 50px">
            <button lay-submit lay-filter="back" class="layui-btn layui-btn-normal layui-btn-radius">退回阳间</button>
            <button lay-submit lay-filter="toutai" class="layui-btn layui-btn-warm layui-btn-radius">安排投胎</button>
            <button lay-submit lay-filter="diyu" class="layui-btn layui-btn-danger layui-btn-radius">关进地狱</button>
            <button id="none" class="layui-btn layui-btn-primary layui-btn-radius">暂不处理</button>
        </div>

    </div>
</form>
<div style="display: none">
    <input type="text" value="" id="datas">
    <input type="text" value="" id="fcountAge">
    <input type="text" value="" id="fcurrentAge">
</div>

<script>
    layui.use(['form', 'layer', 'jquery'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.jquery;

        /*退回阳间*/
        form.on('submit(back)', function (data) {
            if ($("#fcountAge").val() === $("#fcurrentAge").val()) {
                layer.msg("该用户为寿寝正终，无法退回阳间！", {icon: 2, time: 1500});
                return false;
            }
            if ($("#desc").val() === '' || $("#desc").val() === null) {
                layer.msg("审判记录不能为空，请输入！", {icon: 2, time: 1500});
                return false;
            }
            layer.confirm("确认退回阳间吗？", {icon: 3}, function (index) {
                var inf = {
                    info: $("#desc").val()
                };
                $.ajax({
                    type: 'POST',
                    url: '/backOrder/' + $("#datas").val(),
                    data: {info: JSON.stringify(inf)},
                    datatype: 'text',
                    error: function () {
                        layer.alert("系统错误！");
                    },
                    success: function (result) {
                        if (result === 'success') {
                            layer.alert('成功退回！',
                                {
                                    title: '成功',
                                    skin: 'layui-layer-molv',
                                    btn: ['返回'],
                                    anim: 1,
                                    icon: 6,
                                    yes: function () {
                                        parent.layui.table.reload('testId', {
                                            page: {
                                                curr: 1
                                            },
                                        });
                                        layer.close(index);
                                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                                    }
                                });
                        } else {
                            layer.alert('退回失败，继续吗？',
                                {
                                    title: '错误',
                                    skin: 'layui-layer-molv',
                                    btn: ['重试', '退出'],
                                    anim: 1,
                                    icon: 5,
                                    yes: function (index) {
                                        layer.close(index);
                                    },
                                    btn2: function () {
                                        layer.close(index);
                                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                                    }
                                });
                        }
                    }
                });
            });
            return false;
        });

        /*安排投胎*/
        form.on('submit(toutai)', function (data) {
            if ($("#desc").val() === '' || $("#desc").val() === null) {
                layer.msg("审判记录不能为空，请输入！", {icon: 2, time: 1500});
                return false;
            }
            layer.confirm("确认为" + $("#fname label").text() + "安排投胎吗？", {icon: 3}, function (index) {
                var inf = {
                    info: $("#desc").val()
                };
                $.ajax({
                    type: 'POST',
                    url: '/reincarnation/' + $("#datas").val(),
                    data: {info: JSON.stringify(inf)},
                    datatype: 'text',
                    error: function () {
                        layer.alert("系统错误！");
                    },
                    success: function (result) {
                        if (result === 'success') {
                            layer.alert('安排投胎成功！',
                                {
                                    title: '成功',
                                    skin: 'layui-layer-molv',
                                    btn: ['返回'],
                                    anim: 1,
                                    icon: 6,
                                    yes: function () {
                                        parent.layui.table.reload('testId', {
                                            page: {
                                                curr: 1
                                            },
                                        });
                                        layer.close(index);
                                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                                    }
                                });
                        } else {
                            layer.alert('安排投胎失败，继续吗？？',
                                {
                                    title: '错误',
                                    skin: 'layui-layer-molv',
                                    btn: ['重试', '退出'],
                                    anim: 1,
                                    icon: 5,
                                    yes: function (index) {
                                        layer.close(index);
                                    },
                                    btn2: function () {
                                        layer.close(index);
                                        parent.layer.close(parent.layer.getFrameIndex(window.name));
                                    }
                                });
                        }
                    }
                });
            });
            return false;
        });

        /*打入地狱*/
        form.on('submit(diyu)', function (data) {
            if ($("#desc").val() === '' || $("#desc").val() === null) {
                layer.msg("审判记录不能为空，请输入！", {icon: 2, time: 1500});
                return false;
            }
            var index = layer.open({
                title: '打入地狱',
                type: 2,
                shade: 0.2,
                anim: 1,
                shadeClose: true,
                area: ['50%', '60%'],
                content: '/diyu',
                success: function (layero, index) {
                    var body = layer.getChildFrame('body', index);
                    //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                    var iframeWin = window[layero.find('iframe')[0]['name']];
                    body.find('#ids').val($("#ffid label").text());
                    body.find('#names').val($("#fname label").text());
                    body.find('#ind').val(index);
                    body.find('#info').val($("#desc").val());
                    body.find('#id').val($("#datas").val());
                }

            });
            return false;
        });


        /*暂不处理*/
        $("#none").click(function () {
            parent.layer.close(parent.layer.getFrameIndex(window.name));
        })

    });
</script>
</body>
</html>